Skip to content

Conversation

@kerbearasaurus
Copy link
Member

@kerbearasaurus kerbearasaurus commented Jan 13, 2026

use phenoml ts SDK for all bots


Note

Integrates PhenoML TS SDK and adds new automation bots

  • New bots using PhenoML SDK:
    • lang2fhir-create and lang2fhir-document for generating FHIR resources from text/documents
    • phenoml-cohort to analyze natural language into FHIR queries and create Group cohorts
    • phenoml-ips-summary to produce IPS narrative from a patient bundle or fetched resources
    • phenoml-workflow to execute PhenoML workflows by ID with input data
  • Secrets required across bots: PHENOML_EMAIL, PHENOML_PASSWORD.
  • Build/deploy pipeline:
    • build-bots.mjs bundles SDK (esbuild) and outputs to dist/
    • deploy-bots.ts registers all new bots and their compiled artifacts (Lambda runtime)
  • Package updates: adds phenoml (and @huggingface/transformers) dependencies and retains existing scripts with build:bots pipeline.

Written by Cursor Bugbot for commit 2517f4d. This will update automatically on new commits. Configure here.

username: email,
password,
baseUrl: 'https://experiment.app.pheno.ml',
});
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent baseUrl configuration across PhenoML client instances

Medium Severity

The new phenoml-workflow.ts bot explicitly sets baseUrl: 'https://experiment.app.pheno.ml' when creating the PhenoMLClient, but the converted bots (lang2fhir-create.ts, lang2fhir-document.ts, phenoml-cohort.ts) omit this configuration and rely on the SDK's default. The original code in all these bots explicitly used PHENOML_API_URL = "https://experiment.app.pheno.ml". If the SDK's default baseUrl differs from this experiment endpoint, the converted bots will connect to the wrong API environment, causing failures or unexpected behavior.

Additional Locations (2)

Fix in Cursor Fix in Web

throw new Error(`Authentication failed: ${authResponse.status} ${authResponse.statusText}`);
}
// Initialize PhenoML client with automatic auth handling
const phenomlClient = new PhenoMLClient({ username: email, password });
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent baseUrl configuration in PhenoML client initialization

Medium Severity

The refactored bots (lang2fhir-create.ts, lang2fhir-document.ts, phenoml-cohort.ts) initialize PhenoMLClient without a baseUrl, while the new bots (phenoml-workflow.ts, phenoml-ips-summary.ts) explicitly set baseUrl: 'https://experiment.app.pheno.ml'. The old code being replaced explicitly used this URL via PHENOML_API_URL. If the SDK's default differs from this experiment URL, the refactored bots will fail or hit an incorrect endpoint while the new bots work correctly.

Additional Locations (2)

Fix in Cursor Fix in Web

const content = Buffer.from(arrayBuffer).toString('base64');

const contentType = inputDocRef.content?.[0].attachment?.contentType || 'application/pdf';
const fileType = FILE_TYPE_MAP[contentType] || 'application/pdf';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsupported file types silently misrepresented as PDF

Medium Severity

When a document has a content type not in FILE_TYPE_MAP (e.g., 'image/gif', 'image/tiff', 'application/msword'), the code silently falls back to 'application/pdf'. This sends the actual file bytes to the SDK while claiming it's a PDF, which will cause incorrect processing or confusing parsing errors. The old code would pass the actual content type, letting the API validate and reject unsupported types with a clear error. Missing validation for unsupported file types before calling the SDK.

Fix in Cursor Fix in Web

const content = Buffer.from(arrayBuffer).toString('base64');

const contentType = inputDocRef.content?.[0].attachment?.contentType || 'application/pdf';
const fileType = FILE_TYPE_MAP[contentType] || 'application/pdf';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsupported file types silently misrepresented as PDF

Medium Severity

When a document has a content type not in FILE_TYPE_MAP (e.g., 'image/gif', 'image/tiff', 'application/msword'), the code silently falls back to 'application/pdf'. This sends the actual file bytes to the SDK while claiming it's a PDF, which will cause incorrect processing or confusing parsing errors. The old code would pass the actual content type, letting the API validate and reject unsupported types with a clear error. Missing validation for unsupported file types before calling the SDK.

Fix in Cursor Fix in Web

@drdalessandro
Copy link

Brillante! @kerbearasaurus como siempre...! "A Medplum Bot that generates International Patient Summary (IPS) using PhenoML" Felicitaciones, porque siempre están pensado en construir "cosas" "herramientas" que las Personas y los Profesionales necesitan y usarán! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants